#include "alarm_clock.h"


void rotary_callback() {
	if (rotary_pressed()) {
		set_event_signal(ROTARY);
	}
}

void rotary_callback_with_debounce() {
	scheduler_add(rotary_callback, 50);
}

void joystick_callback() {
	if (joystick_pressed())

		set_event_signal(JOYSTICK);
}

void joystick_callback_with_debounce() {
	scheduler_add(joystick_callback, 50);
}

//void dispatch_interrupt() {
//	fsm_dispatching();
//	scheduler_add(dispatch_interrupt, 1);
//}

int main() {

	// initialize phase
//	buzzer_init();
	Fsm * fsm = malloc(sizeof(Fsm));
	State initState= alarmClock_set_hours;
	scheduler_init();
	alarmClock_init(fsm, initState);
//	toggle_buzz();
	button_setRotaryButtonCallback(rotary_callback_with_debounce);
	button_setJoystickButtonCallback(joystick_callback_with_debounce);

	scheduler_run();

	return 0;
}
